{% extends "_base.html" %}

{% block main %}

<script>
    $(function () {
        $('#questionForm').submit(function (e) {
            e.preventDefault();
            var data = {
                title: $('#Title').val(),
                questionDetails: $('#floatingTextarea2').val(),
                sponsor_id: $('#accountID').val()
            };
            $.ajax({
                type: 'post',
                url: '/postQuestion',
                data: JSON.stringify(data),
                success: function (resp) {
                    if (resp.error) {
                        // $('#error').text(resp.error);
                        location.assign('/signinIndex');
                        $('#error').text(resp.error);
                    } else {
                        location.assign('/');
                    }
                },
                contentType: 'application/json',
                dataType: 'json'
            });
        });
    });
</script>
<meta charset="utf-8">
<ul class="nav justify-content-center">
    <li class="nav-item">
        <a class="nav-link active" aria-current="page" href="\">首页</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="signinIndex">登录</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="register">注册</a>
    </li>
    <li class="nav-item">
        <a class="nav-link" href="profile" tabindex="-1" aria-disabled="true">我的</a>
    </li>
</ul>

<form id="questionForm">
<div class="container">
    <div class="form-floating">
        <input id="Title" type="text" class="form-control" placeholder="标题"><br>
        <input id="accountID" type="text" style="display:none; color:  #fdfdfe" value="{{account.accountID}}" >
        <textarea class="form-control" placeholder="在这里发表你的心情，问题，需求..." id="floatingTextarea2" style="height: 180px"></textarea>
    </div>
    <button type="submit" class="btn btn-primary" style="float: right;margin-top: 20px;">发布</button>
</div>
</form>

<div class="contai112121ner" style="margin:100px auto;">
    <div class="card">
        <div class="card-header">
            标签：生物/科学
        </div>
        <div class="card-body">
            <h5 class="card-title"><a id="link3" href="afterPostQuestion?id={{q1.questionID}}">问题标题：{{ q2.title}}</a></h5>
            <p class="card-text">详细：{{ q2.questionDetails}}</p>
            <p class="card-text">提问人：{{ q2.sponsor_id}}</p>
            <a href="answer" class="btn btn-primary" style="float: right;">立即回答</a>
        </div>
    </div>
</div>

<div class="container" style="margin:100px auto;">
    <div class="card">
        <div class="card-header">
            标签：生物/科学
        </div>
        <div class="card-body">
            <h5 class="card-title"><a id="link2" href="afterPostQuestion?id={{q1.questionID}}">问题标题：{{ q3.title}}</a></h5>
            <p class="card-text">详细：{{ q3.questionDetails}}</p>
            <p class="card-text">提问人：{{ q2.sponsor_id}}</p>
            <a href="answer" class="btn btn-primary" style="float: right;">立即回答</a>
        </div>
    </div>
</div>

<div class="container" style="margin:0 auto;">
    <div class="card">
        <div class="card-header">
            标签：生物/科学
        </div>
        <div class="card-body">
            <h5 class="card-title"><a id="link" href="afterPostQuestion?id={{q1.questionID}}">问题标题：{{ q1.title}}</a></h5>
            <p class="card-text">详细：{{ q1.questionDetails}}</p>
            <p class="card-text">提问人：{{ q2.sponsor_id}}</p>
            <a href="answer" class="btn btn-primary" style="float: right;">立即回答</a>
        </div>
    </div>
</div>

{% endblock %}
